<?php
if (!defined('CMS_SYSTEM')) die();
if ($disable_site) {
	echo "<center style=\"margin-top:200px;font-weight:bold\">".$disable_message ."</center>";
}else{
global $db,$Default_Temp, $time, $currentlang,$prefix;
if (file_exists(DATAFOLD."/config_introduce.php")) {
	include_once(DATAFOLD."/config_introduce.php");
}
include_once("templates/".$Default_Temp."/header.php");
  include_once("templates/".$Default_Temp."/banner.php");
  include_once("templates/".$Default_Temp."/menu.php");
  /*
   * Phan loc ra tat ca tin tuc
   * Le duc vien
   */
  /*
   * phan phan trang 
   * Le duc vien
   */
     $perpage = $perpage;
     $page = intval(isset($_GET['page']) ? $_GET['page'] : (isset($_POST['page']) ? $_POST['page']:1));
	 $offset = ($page-1) * $perpage;
	 $countf = $db->sql_fetchrow($db->sql_query("SELECT COUNT(*) FROM {$prefix}_news WHERE active='1' AND alanguage='$currentlang'"));
	 $total = ($countf[0]) ? $countf[0] : 1;
	 $pageurl = "index.php?f=$module_name";
  /*
   * Ket thuc phan phan trag
   */
 echo "<div id=\"wrapper\">";
	 echo "<div class=\"content fix\">";
	     //Noi dung phan loc tat ca san pham
	     echo "<div class=\"w720 fl\">";
	       echo "<div class=\"common\">";
	            echo "<div class=\"title\">";
				 echo "<h1 class=\"text\"><a href=\"".url_sid("index.php?f=news")."\"><span>"._NEWS_TOTAL."</a></h1>";
			    echo "</div>";
			    echo "<div class=\"wrap fix\">";
			    $result_prds_index = $db->sql_query("SELECT id, title, images,hometext,imgtext,source FROM {$prefix}_news WHERE active='1' AND alanguage='$currentlang' ORDER BY time DESC LIMIT $offset, $perpage");
                if($db->sql_numrows($result_prds_index) > 0) {
                	while(list($id, $title, $images,$hometext,$imgtext,$source) = $db->sql_fetchrow($result_prds_index)) 
                	{
                		$urlid = "$siteurl/".url_sid("index.php?f=$module_name&do=detail&id=$id");
                		$get_path = get_path(time());
		                $path_upload_img = "$path_upload/news/$get_path";
	                	 echo "<div class=\"news\">";
									echo "<h2 class=\"name\"><a href=\"".$urlid."\" title=\"\">$title</a></h2>";
									echo "<div class=\"article fix\">";
										if($images=="")
										{
										     echo "<img width='$sizenews' src=\"images/nopic2.gif\" alt=\"\"/>";
										}else {
											
											 echo "<img width='$sizenews' src=\"$path_upload_img/$images\" alt=\"\"/>";
										}
										echo "</a>";
										echo "<p class=\"short\">";
											echo "$hometext"; 
										echo "</p>";	
										echo "<p>";
											echo "<a href=\"".$urlid."\" class=\"readmore\">"._VIEW_DETAIL."</a>";
										echo "</p>";
									echo "</div>";
						echo "</div>";
                	}
                	echo "<div class=\"clear\"></div>";	
                	if($total > $perpage) {		
						echo "<div class=\"page fix\">";
						   echo paging_theme($total,$pageurl,$perpage,$page);
					echo "</div>";
                	}
                }else{
				  	echo "<div style=\"text-align:center;padding-top:10px\">"._NEWS_NULL."</div>";
				  }
			    echo "</div>";
	       echo "</div>";
	     echo "</div>";
	     include_once("templates/".$Default_Temp."/rightbody.php");
	 echo "</div>";
	 themeSlideShow(8);
	 themeFooter();
 echo "</div>";
 /*
  * Ket thuc phan tin tuc
  * 
  */
}	
?>